﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CopySniffer.Common
{
    public static class CollectionsExtender
    {
        public static void ForEach<T>(this IEnumerable<T> list, Action<T> action)
        {
            foreach (T item in list)
            {
                action(item);
            }
        }

        public static List<TDestiny> ToList<TDestiny, TSource>(
            this IEnumerable<TSource> list, 
            Func<TSource, TDestiny> convert)
        {
            List<TDestiny> result = new List<TDestiny>();
            list.ForEach(i => result.Add(convert(i)));
            return result;
        }

    }
}
